package com.ruben.strategies.exapmle;

import java.util.List;

/**
 * 导航
 *
 * @author <achao1441470436@gmail.com>
 * @since 2021/10/16 19:31
 */
public class Navigator {

    private RouteStrategy routeStrategy;

    /**
     * 构造函数
     *
     * @param routeStrategy 策略
     */
    public Navigator(RouteStrategy routeStrategy) {
        this.routeStrategy = routeStrategy;
    }

    /**
     * 设置路线规划策略，应变策略变更的情况
     *
     * @param routeStrategy 策略
     */
    public void setRouteStrategy(RouteStrategy routeStrategy) {
        this.routeStrategy = routeStrategy;
    }

    /**
     * 路线规划
     *
     * @param start 起点
     * @param end   终点
     * @return 路线
     */
    public List<String> buildRoute(String start, String end) {
        System.out.println("用户选择了：" + routeStrategy.getClass().getSimpleName());
        System.out.println("起点为：" + start);
        System.out.println("终点为：" + end);
        return this.routeStrategy.buildRoute(start, end);
    }

}
